package handler

import (
    "fcs-api/src/app/model"
    "net/http"

    i18n "git.inspur.com/x/common/i18n"
    "github.com/emicklei/go-restful"
)

func (api *APIHandler) handleGetUserStatus(request *restful.Request, response *restful.Response) {
    user := currentUser(request)
    order, err := model.GetOrderByAccountId(user.AccountId)
    if err != nil {
        handleInternalError(response, model.InternalServerError(model.OrderHandleError, i18n.GetMessage(request.Request, "fcs.order.query")))
        return
    }
    if order == nil {
        handleInternalError(response, model.InternalServerError(model.OrderHandleError, i18n.GetMessage(request.Request, "fcs.order.has")))
        return
    }
    _ = response.WriteHeaderAndEntity(http.StatusOK, map[string]interface{}{"status": order.Status})
}
